package com.chat.utils;

import javafx.scene.Parent;
import javafx.stage.Stage;
/*
  设置任何位置都可以拖动场景
 */
public class MouseFollow {
    double x;
    double y;
    public MouseFollow(Parent root, Stage primaryStage){
         root.setOnMousePressed(event -> {
              x=event.getSceneX();
              y=event.getSceneY();
         });
         root.setOnMouseDragged(event -> {
             primaryStage.setX(event.getScreenX()-x);
             primaryStage.setY(event.getScreenY()-y);
         });
    }
}
